﻿using UnityEngine.UI;

namespace Game
{
    public class SceneHpBarEntity : GameObjectContainerEntity
    {
        private Image _hpImage;
        private float _hpPercent;
        
        public void LoadHpBar()
        {
            Load("Assets/Game/Assets/UI/Hp/HpBar.prefab");
        }

        public void SetHpPercent(float percent)
        {
            _hpPercent = percent;
            if (_hpImage != null)
            {
                _hpImage.fillAmount = _hpPercent;
            }   
        }

        protected override void PostInstantiate()
        {
            _hpImage = _contentTransform.Find("Hp").GetComponent<Image>();
            OnPostInstantiateCompleted();
        }
    }
}